<template>
  <HomePanel ref="target" title="人气推荐" sub-title="人气推荐 不容错过">
    <!-- 面板内容 -->
    <div class="home-hot">
      <Transition name="fade">
        <ul class="goods-list" v-if="list.length">
          <li v-for="item in list" :key="item.id">
            <RouterLink to="/">
              <img :src="item.picture" />
              <p class="name ellipsis">{{ item.title }}</p>
              <p class="desc">{{ item.alt }}</p>
            </RouterLink>
          </li>
        </ul>
        <HomeSkeleton v-else name="fade"></HomeSkeleton>
      </Transition>
    </div>
  </HomePanel>
</template>
<script>
import HomeSkeleton from './home-skeleton.vue'
import { useLazyData } from '@/utils/hooks.js'
// import { ref, onMounted } from 'vue'
import { getHot } from '@/api/home.js'
import HomePanel from './home-panel'
export default {
  name: 'HomeHot',
  components: { HomePanel, HomeSkeleton },
  setup() {
    // const list = ref([])
    // onMounted(async () => {
    //   const data = await getHot()
    //   list.value = data.result
    // })
    const { target, list } = useLazyData(getHot)
    return { target, list }
  }
}
</script>
<style scoped lang="less">
.home-hot {
  position: relative;
  height: 426px;
}
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    transition: all 0.5s;
    &:hover {
      transform: translate3d(0, -3px, 0);
      box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    }
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>
